package com.mt.operation.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.mt.common.PagerInfo;
import com.mt.common.ServiceResult;
import com.mt.common.constants.BaseErrorConstants;
import com.mt.operation.api.service.IHomePageOperationCategoryService;
import com.mt.operation.entity.HomePageOperationCategoryEntity;
import com.mt.operation.mapper.HomePageOperationCategoryEntityMapper;
import com.mt.operation.service.model.HomePageOperationCategoryServiceModel;

@Service
public class HomePageOperationCategoryServiceImpl implements IHomePageOperationCategoryService {

    private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(HomePageOperationCategoryServiceImpl.class);

    @Autowired
    private HomePageOperationCategoryServiceModel homePageOperationCategoryServiceModel;



    @Autowired
    private HomePageOperationCategoryEntityMapper homePageOperationCategoryEntityMapper;

    public ServiceResult<List<HomePageOperationCategoryEntity>> findList(Map<String, Object> params,
            PagerInfo<?> pagerInfo) {
        ServiceResult<List<HomePageOperationCategoryEntity>>
            result = new ServiceResult<List<HomePageOperationCategoryEntity>>();
        try {
            result = homePageOperationCategoryServiceModel.selectList(params, pagerInfo);
        } catch (Exception e) {
            LOGGER.error("[HomePageOperationCategoryServiceImpl][findList]：query findList occur exception", e);
            result.setError(BaseErrorConstants.ERROR_CODE_SERVICE_CONTROLLER, "查询列表错误");
        }

        return result;
    }

    public ServiceResult<HomePageOperationCategoryEntity> findInfo(Map<String, Object> params) {
        ServiceResult<HomePageOperationCategoryEntity> result = null;
        HashMap<String, Object> selectNoTopMap = null;
        // 该参数标识前段是否需要权限数据
        try {

            result = homePageOperationCategoryServiceModel.selectInfo(params);
        } catch (Exception e) {
            LOGGER.error("[HomePageOperationCategoryServiceImpl][findInfo]：query findInfo occur exception", e);
            result.setError(BaseErrorConstants.ERROR_CODE_SERVICE_CONTROLLER, "查询详情错误");
        }
        return result;
    }

    public ServiceResult<Integer> doInsert(HomePageOperationCategoryEntity homePageOperationCategoryEntity) {
        ServiceResult<Integer> result = new ServiceResult<Integer>();
        try {

            result = homePageOperationCategoryServiceModel.insert(homePageOperationCategoryEntity);

        } catch (Exception e) {
            LOGGER.error("[HomePageOperationCategoryServiceImpl][doInsert]：query doInsert occur exception", e);
            result.setError(BaseErrorConstants.ERROR_CODE_SERVICE_CONTROLLER, "创建信息错误");
        }
        return result;
    }

    public ServiceResult<Integer> doUpdate(HomePageOperationCategoryEntity homePageOperationCategoryEntity) {
        ServiceResult<Integer> result = new ServiceResult<Integer>();
        Map<String, Object> map = null;
        try {

            result = homePageOperationCategoryServiceModel.updateByPrimaryKeySelective(homePageOperationCategoryEntity);
        } catch (Exception e) {
            LOGGER.error("[HomePageOperationCategoryServiceImpl][doUpdate]：query doUpdate occur exception", e);
            result.setError(BaseErrorConstants.ERROR_CODE_SERVICE_CONTROLLER, "更新信息错误.");
        }
        return result;
    }

    public ServiceResult<Integer> doDeleteById(Integer homePageOperationCategoryId) {
        ServiceResult<Integer> result = new ServiceResult<Integer>();
        try {

            result = homePageOperationCategoryServiceModel.deleteByPrimaryKey(homePageOperationCategoryId);

        } catch (Exception e) {
            LOGGER.error("[NewComerPackageLogServiceImpl][doDeleteById]：query doDeleteById occur exception", e);
            result.setError(BaseErrorConstants.ERROR_CODE_SERVICE_CONTROLLER, "删除信息错误");
        }
        return result;
    }
}
